.TH std::remove_cvref 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::remove_cvref \- std::remove_cvref

.SH Synopsis
   Defined in header <type_traits>
   template< class T >              \fI(since C++20)\fP
   struct remove_cvref;

   If the type T is a reference type, provides the member typedef type which is the
   type referred to by T with its topmost cv-qualifiers removed. Otherwise type is T
   with its topmost cv-qualifiers removed.

   If the program adds specializations for std::remove_cvref, the behavior is
   undefined.

.SH Member types

   Name Definition
   type the type referred by T or T itself if it is not a reference, with top-level
        cv-qualifiers removed

.SH Helper types

   template< class T >                            \fI(since C++20)\fP
   using remove_cvref_t = remove_cvref<T>::type;

.SH Possible implementation

   template<class T>
   struct remove_cvref
   {
       using type = std::remove_cv_t<std::remove_reference_t<T>>;
   };

.SH Notes

     Feature-test macro    Value    Std        Feature
   __cpp_lib_remove_cvref 201711L (C++20) std::remove_cvref

.SH Example


// Run this code

 #include <type_traits>

 int main()
 {
     static_assert(std::is_same_v<std::remove_cvref_t<int>, int>);
     static_assert(std::is_same_v<std::remove_cvref_t<int&>, int>);
     static_assert(std::is_same_v<std::remove_cvref_t<int&&>, int>);
     static_assert(std::is_same_v<std::remove_cvref_t<const int&>, int>);
     static_assert(std::is_same_v<std::remove_cvref_t<const int[2]>, int[2]>);
     static_assert(std::is_same_v<std::remove_cvref_t<const int(&)[2]>, int[2]>);
     static_assert(std::is_same_v<std::remove_cvref_t<int(int)>, int(int)>);
 }

.SH See also

   remove_cv
   remove_const
   remove_volatile  removes const and/or volatile specifiers from the given type
   \fI(C++11)\fP          \fI(class template)\fP
   \fI(C++11)\fP
   \fI(C++11)\fP
   remove_reference removes a reference from the given type
   \fI(C++11)\fP          \fI(class template)\fP
   decay            applies type transformations as when passing a function argument by
   \fI(C++11)\fP          value
                    \fI(class template)\fP
